1 <cfcomponent output="false" displayname="FCKeditor" hint="Create an instance of the FCKeditor.">
2
3 <!---
4  * FCKeditor - The text editor
for Internet - http://www.fckeditor.net
5  * Copyright (C)
2003-2008 Frederico Caldeira Knabben
6  *
7  * == BEGIN LICENSE ==
8  *
9  * Licensed under the terms of any of the following licenses at your
10  * choice:
11  *
12  * - GNU General Public License Version
2 or later (the "GPL")
13  * http:
//www.gnu.org/licenses/gpl.html
14  *
15  * - GNU Lesser General Public License Version
2.1 or later (the "LGPL")
16  * http:
//www.gnu.org/licenses/lgpl.html
17  *
18  * - Mozilla Public License Version
1.1 or later (the "MPL")
19  * http:
//www.mozilla.org/MPL/MPL-1.1.html
20  *
21  * == END LICENSE ==
22  *
23  * ColdFusion MX integration.
24  * Note
this CFC is created for use only with Coldfusion MX and above.
25  * For older version, check the fckeditor.cfm.
26  *
27  * Syntax:
28  *
29  * <cfscript>
30  * fckEditor = createObject(
"component", "fckeditor.fckeditor");
31  * fckEditor.instanceName=
"myEditor";
32  * fckEditor.basePath=
"/fckeditor/";
33  * fckEditor.
value="<p>This is my <strong>initial</strong> html text.</p>";
34  * fckEditor.width=
"100%";
35  * fckEditor.height=
"200";
36  *
// ... additional parameters ...
37  * fckEditor.create();
// create instance now.
38  * </cfscript>
39  *
40  * See your macromedia coldfusion mx documentation
for more info.
41  *
42  * *** Note:
43  * Do not use path names with a
"." (dot) in the name. This is a coldfusion
44  * limitation with the cfc invocation.
45 --->
46
47 <cfinclude template=
"fckutils.cfm">
48
49 <cffunction
50     name=
"Create"
51     access=
"public"
52     output=
"true"
53     returntype=
"void"
54     hint=
"Outputs the editor HTML in the place where the function is called"
55 >
56     <cfoutput>#CreateHtml()#</cfoutput>
57 </cffunction>
58
59 <cffunction
60     name=
"CreateHtml"
61     access=
"public"
62     output=
"false"
63     returntype=
"string"
64     hint=
"Retrieves the editor HTML"
65 >
66
67     <cfparam name=
"this.instanceName" type="string" />
68     <cfparam name=
"this.width" type="string" default="100%" />
69     <cfparam name=
"this.height" type="string" default="200" />
70     <cfparam name=
"this.toolbarSet" type="string" default="Default" />
71     <cfparam name=
"this.value" type="string" default="" />
72     <cfparam name=
"this.basePath" type="string" default="/fckeditor/" />
73     <cfparam name=
"this.checkBrowser" type="boolean" default="true" />
74     <cfparam name=
"this.config" type="struct" default="#structNew()#" />
75
76     <cfscript>
77     
// display the html editor or a plain textarea?
78     
if( isCompatible() )
79         
return getHtmlEditor();
80     
else
81         
return getTextArea();
82     </cfscript>
83
84 </cffunction>
85
86 <cffunction
87     name=
"isCompatible"
88     access=
"private"
89     output=
"false"
90     returnType=
"boolean"
91     hint=
"Check browser compatibility via HTTP_USER_AGENT, if checkBrowser is true"
92 >
93
94     <cfscript>
95     
var sAgent = lCase( cgi.HTTP_USER_AGENT );
96     
var stResult = "";
97     
var sBrowserVersion = "";
98
99     
// do not check if argument "checkBrowser" is false
100     
if( not this.checkBrowser )
101         
return true;
102
103     
return FCKeditor_IsCompatibleBrowser();
104     </cfscript>
105 </cffunction>
106
107 <cffunction
108     name=
"getTextArea"
109     access=
"private"
110     output=
"false"
111     returnType=
"string"
112     hint=
"Create a textarea field for non-compatible browsers."
113 >
114     <cfset
var result = "" />
115     <cfset
var sWidthCSS = "" />
116     <cfset
var sHeightCSS = "" />
117
118     <cfscript>
119     
if( Find( "%", this.width ) gt 0)
120         sWidthCSS =
this.width;
121     
else
122         sWidthCSS =
this.width & "px";
123
124     
if( Find( "%", this.width ) gt 0)
125         sHeightCSS =
this.height;
126     
else
127         sHeightCSS =
this.height & "px";
128
129     result =
"<textarea name=""#this.instanceName#"" rows=""4"" cols=""40"" style=""width: #sWidthCSS#; height: #sHeightCSS#"">#HTMLEditFormat(this.value)#</textarea>" & chr(13) & chr(10);
130     </cfscript>
131     <cfreturn result />
132 </cffunction>
133
134 <cffunction
135     name=
"getHtmlEditor"
136     access=
"private"
137     output=
"false"
138     returnType=
"string"
139     hint=
"Create the html editor instance for compatible browsers."
140 >
141     <cfset
var sURL = "" />
142     <cfset
var result = "" />
143
144     <cfscript>
145     
// try to fix the basePath, if ending slash is missing
146     
if( len( this.basePath) and right( this.basePath, 1 ) is not "/" )
147         
this.basePath = this.basePath & "/";
148
149     
// construct the url
150     sURL =
this.basePath & "editor/fckeditor.html?InstanceName=" & this.instanceName;
151
152     
// append toolbarset name to the url
153     
if( len( this.toolbarSet ) )
154         sURL = sURL &
"&amp;Toolbar=" & this.toolbarSet;
155     </cfscript>
156
157     <cfscript>
158     result = result &
"<input type=""hidden"" id=""#this.instanceName#"" name=""#this.instanceName#"" value=""#HTMLEditFormat(this.value)#"" style=""display:none"" />" & chr(13) & chr(10);
159     result = result &
"<input type=""hidden"" id=""#this.instanceName#___Config"" value=""#GetConfigFieldString()#"" style=""display:none"" />" & chr(13) & chr(10);
160     result = result &
"<iframe id=""#this.instanceName#___Frame"" src=""#sURL#"" width=""#this.width#"" height=""#this.height#"" frameborder=""0"" scrolling=""no""></iframe>" & chr(13) & chr(10);
161     </cfscript>
162     <cfreturn result />
163 </cffunction>
164
165 <cffunction
166     name=
"GetConfigFieldString"
167     access=
"private"
168     output=
"false"
169     returnType=
"string"
170     hint=
"Create configuration string: Key1=Value1&Key2=Value2&... (Key/Value:HTML encoded)"
171 >
172     <cfset
var sParams = "" />
173     <cfset
var key = "" />
174     <cfset
var fieldValue = "" />
175     <cfset
var fieldLabel = "" />
176     <cfset
var lConfigKeys = "" />
177     <cfset
var iPos = "" />
178
179     <cfscript>
180     
/**
181      * CFML doesn
't store casesensitive names for structure keys, but the configuration names must be casesensitive for js.
182      * So we need to find
out the correct case for the configuration keys.
183      * We
"fix" this by comparing the caseless configuration keys to a list of all available configuration options in the correct case.
184      * changed
20041206 hk@lwd.de (improvements are welcome!)
185      */

186     lConfigKeys = lConfigKeys &
"CustomConfigurationsPath,EditorAreaCSS,ToolbarComboPreviewCSS,DocType";
187     lConfigKeys = lConfigKeys &
",BaseHref,FullPage,Debug,AllowQueryStringDebug,SkinPath";
188     lConfigKeys = lConfigKeys &
",PreloadImages,PluginsPath,AutoDetectLanguage,DefaultLanguage,ContentLangDirection";
189     lConfigKeys = lConfigKeys &
",ProcessHTMLEntities,IncludeLatinEntities,IncludeGreekEntities,ProcessNumericEntities,AdditionalNumericEntities";
190     lConfigKeys = lConfigKeys &
",FillEmptyBlocks,FormatSource,FormatOutput,FormatIndentator";
191     lConfigKeys = lConfigKeys &
",StartupFocus,ForcePasteAsPlainText,AutoDetectPasteFromWord,ForceSimpleAmpersand";
192     lConfigKeys = lConfigKeys &
",TabSpaces,ShowBorders,SourcePopup,ToolbarStartExpanded,ToolbarCanCollapse";
193     lConfigKeys = lConfigKeys &
",IgnoreEmptyParagraphValue,FloatingPanelsZIndex,TemplateReplaceAll,TemplateReplaceCheckbox";
194     lConfigKeys = lConfigKeys &
",ToolbarLocation,ToolbarSets,EnterMode,ShiftEnterMode,Keystrokes";
195     lConfigKeys = lConfigKeys &
",ContextMenu,BrowserContextMenuOnCtrl,FontColors,FontNames,FontSizes";
196     lConfigKeys = lConfigKeys &
",FontFormats,StylesXmlPath,TemplatesXmlPath,SpellChecker,IeSpellDownloadUrl";
197     lConfigKeys = lConfigKeys &
",SpellerPagesServerScript,FirefoxSpellChecker,MaxUndoLevels,DisableObjectResizing,DisableFFTableHandles";
198     lConfigKeys = lConfigKeys &
",LinkDlgHideTarget,LinkDlgHideAdvanced,ImageDlgHideLink,ImageDlgHideAdvanced,FlashDlgHideAdvanced";
199     lConfigKeys = lConfigKeys &
",ProtectedTags,BodyId,BodyClass,DefaultLinkTarget,CleanWordKeepsStructure";
200     lConfigKeys = lConfigKeys &
",LinkBrowser,LinkBrowserURL,LinkBrowserWindowWidth,LinkBrowserWindowHeight,ImageBrowser";
201     lConfigKeys = lConfigKeys &
",ImageBrowserURL,ImageBrowserWindowWidth,ImageBrowserWindowHeight,FlashBrowser,FlashBrowserURL";
202     lConfigKeys = lConfigKeys &
",FlashBrowserWindowWidth,FlashBrowserWindowHeight,LinkUpload,LinkUploadURL,LinkUploadWindowWidth";
203     lConfigKeys = lConfigKeys &
",LinkUploadWindowHeight,LinkUploadAllowedExtensions,LinkUploadDeniedExtensions,ImageUpload,ImageUploadURL";
204     lConfigKeys = lConfigKeys &
",ImageUploadAllowedExtensions,ImageUploadDeniedExtensions,FlashUpload,FlashUploadURL,FlashUploadAllowedExtensions";
205     lConfigKeys = lConfigKeys &
",FlashUploadDeniedExtensions,SmileyPath,SmileyImages,SmileyColumns,SmileyWindowWidth,SmileyWindowHeight";
206
207     
for( key in this.config )
208     {
209         iPos = listFindNoCase( lConfigKeys, key );
210         
if( iPos GT 0 )
211         {
212             
if( len( sParams ) )
213                 sParams = sParams &
"&amp;";
214
215             fieldValue =
this.config[key];
216             fieldName = listGetAt( lConfigKeys, iPos );
217
218             
// set all boolean possibilities in CFML to true/false values
219             
if( isBoolean( fieldValue) and fieldValue )
220                 fieldValue =
"true";
221             
else if( isBoolean( fieldValue) )
222                 fieldValue =
"false";
223
224             sParams = sParams & HTMLEditFormat( fieldName ) &
'=' & HTMLEditFormat( fieldValue );
225         }
226     }
227     
return sParams;
228     </cfscript>
229
230 </cffunction>
231
232 </cfcomponent>



Full source code website bán hàng thương mại điện tử gần giống shopee 473.157 lượt xem

Gõ tìm kiếm nhanh...